<template>
    <data-form ref="dataFormRef" :enums="enums" :forms="forms" description="文件仓"/>
</template>

<script lang="ts" setup>
import { ref} from 'vue'
import {service} from "@/utils";
import DataForm from "@/components/data-form/index.vue";

const dataFormRef = ref<InstanceType<typeof DataForm>>();
const enums= ref({
    defaultFileDatabaseId: []
});
const forms = ref([
    {prop: 'id'},
    {prop: 'name', label: '名称', required: true},
    {prop: 'defaultFileDatabaseId', label: '文件库', el: 'select'},
    {prop: 'tempPath', label: '临时路径', required: true}
])

const open = (options: OpenFormConfig) => {
    service.get('/fileSystem/fileDatabase').then(({data}) => {
        if (data) {
            enums.value.defaultFileDatabaseId = data.rows.map((item: any) => ({label: item.name, title: item.path, value: item.id}));
            dataFormRef.value?.open(options);
        }
    })

}

defineExpose({open})
</script>